import java.util.Stack;

public class Solution {
    private Stack<Integer> A;
    private Stack<Integer> B;

    public Solution() {
        A = new Stack<>();
        B = new Stack<>();
    }

    public void push(int x) {
        A.push(x);
    }

    public int pop() {
        int peek = peek();
        B.pop();
        return peek;
    }

    public int peek() {
        if (!B.isEmpty()) return B.peek();
        if (A.isEmpty()) return -1;
        while (!A.isEmpty()) {
            B.push(A.pop());
        }
        return B.peek();
    }

    public boolean empty() {
        return A.isEmpty() && B.isEmpty();
    }

    public static void main(String[] args) {
        Solution queue = new Solution();

        queue.push(1);
        queue.push(2);
        queue.push(3);

        System.out.println("Peek: " + queue.peek()); // 应该输出 1
        System.out.println("Pop: " + queue.pop());  // 应该输出 1
        System.out.println("Peek: " + queue.peek()); // 应该输出 2
        System.out.println("Pop: " + queue.pop());  // 应该输出 2
        System.out.println("Empty: " + queue.empty()); // 应该输出 false
        System.out.println("Pop: " + queue.pop());  // 应该输出 3
        System.out.println("Empty: " + queue.empty()); // 应该输出 true
    }
}